<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

<%@page import="java.util.List"%>
<%@page import="grupobbva.pe.operhc.util.Constant"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%
String versionApp=(String)request.getSession().getAttribute(Constant.VERSIONAPP_SESSION);
%>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel="stylesheet" type="text/css" media="screen" href="<%=request.getContextPath()%>/css/ui.jqgrid.css" />
	<link rel="stylesheet" type="text/css" media="screen" href="<%=request.getContextPath()%>/css/redmond/jquery-ui-1.8.2.custom.css" />
	<link rel="stylesheet" type="text/css" media="screen" href="<%=request.getContextPath()%>/css/operhc_style.css" />
	
	<script src="<%=request.getContextPath()%>/js/util/gridUtil.js" type="text/javascript"></script>
	<script src="<%=request.getContextPath()%>/js/jquery-1.7.1.js" type="text/javascript"></script>	
	<script src="<%=request.getContextPath()%>/js/i18n/grid.locale-es.js" type="text/javascript"></script>
	<script src="<%=request.getContextPath()%>/js/jquery.jqGrid.src.js" type="text/javascript"></script>
	<script src="<%=request.getContextPath()%>/js/grid.subgrid.js" type="text/javascript"></script>
	<script src="<%=request.getContextPath()%>/js/util/encabezado.js?ver<%=versionApp%>" type="text/javascript"></script>
	
	<script type="text/javascript" charset="UTF-8">
	
	function validacionFormVal(){
		
		var formulario = document.getElementById('formCalculo');
		var limiteAjust = formulario.limiteAjustVal.value;
		var tasa  = formulario.tasaVal.value;
		var plazo = formulario.plazoVal.value;
		
		if(limiteAjust == ''){
			alert('El limite ajustado es un campo obligatorio.');
			return false;
		}else if(tasa == ''){
			alert('La tasa es un campo obligatorio.');
			return false;
		}else if(plazo == ''){
			alert('El plazo es un campo obligatorio.');
			return false;
		}
		
		formulario.action = "adminForm.do?method=calcularCuota";
		formulario.submit();
	}
	
	function validacionForm(){
		
		var formulario = document.getElementById('formCalculo');
		var cuota = formulario.cuota.value;
		var tasa  = formulario.tasa.value;
		var plazo = formulario.plazo.value;
		
		if(cuota == ''){
			alert('La cuota es un campo obligatorio.');
			return false;
		}else if(tasa == ''){
			alert('La tasa es un campo obligatorio.');
			return false;
		}else if(plazo == ''){
			alert('El plazo es un campo obligatorio.');
			return false;
		}

		formulario.submit();
	}
	
	</script>
</head>
<body>
<html:form styleId="formCalculo" method="post" action="adminForm.do?method=calcularLimite">
	
	<div style="background-color: #0066bb;">
		<font face="Arial Narrow" size=3 color="#FFFFFF"><b>&nbsp;Cálculo del Nuevo Límite</b></font>
	</div>
	
	<center>
	<%
	Object messageError = request.getAttribute("messageError");
	if(messageError != null){
		if(messageError instanceof List){
			
			List listMsg = (List)messageError;
			if(!listMsg.isEmpty()){%>
				
				<div class="error">
					<% 
					for(int i = 0; i < listMsg.size(); i++){%>
						<img alt="" src="images/icono_error.png" width="17px" height="17px" class="icon">
			    		<%=listMsg.get(i)%><br/>
					<%}
					%>	
				</div>
			<%}			
			
		}else{
			if(!"".equals(messageError)){%>
				
				<div class="error">
			    	<img alt="" src="images/icono_error.png" width="17px" height="17px" class="icon">
			    	<%=messageError%><br/>
			    </div>				
			<%}
		}
	}
	%>
	

	<%
	Object messageInfo = request.getAttribute("messageInfo");
	if(messageInfo != null){
		if(messageInfo instanceof List){
			
			List listMsg = (List)messageInfo;
			if(!listMsg.isEmpty()){%>
				
				<div class="message">
					<% 
					for(int i = 0; i < listMsg.size(); i++){%>
						<img alt="" src="images/information-icon.png" width="17px" height="17px" class="icon">
			    		<%=listMsg.get(i)%><br/>
					<%}
					%>	
				</div>
			<%}			
			
		}else{
			if(!"".equals(messageInfo)){%>
				
				<div class="message">
			    	<img alt="" src="images/information-icon.png" width="17px" height="17px" class="icon">
			    	<%=messageInfo%><br/>
			    </div>				
			<%}
		}
	}
	%>
	</center>
	
	<br/>
	<table width="50%" height="100%" border="0" cellspacing="0" cellpadding="0">
	
	<tr>
	<td>Cuota</td>
	<td align="left"><html:text property="cuota" styleId="cuota" style="width: 150px"/></td>
	</tr>
	
	<tr>
	<td>Tasa</td>
	<td align="left"><html:text property="tasa" styleId="tasa" style="width: 150px"/></td>
	</tr>
	
	<tr>
	<td>Plazo</td>
	<td align="left"><html:text property="plazo" styleId="plazo" style="width: 150px"/></td>
	</tr>
	
	<tr>
		<td colspan="2">&nbsp;</td>
	</tr>
	
	<tr>
	<td>Limite Real</td>
	<td align="left"><html:text property="limiteReal" styleId="limiteReal" style="width: 150px"/></td>
	</tr>
	
	<tr>
	<td>Limite Ajustado</td>
	<td align="left"><html:text property="limiteAjust" styleId="limiteAjust" style="width: 150px"/></td>
	</tr>
	
	<tr>
	<td>Cuota Ajustada</td>
	<td align="left"><html:text property="cuotaAjust" styleId="cuotaAjust" style="width: 150px"/></td>
	</tr>
	
	<tr>
		<td colspan="2">&nbsp;</td>
	</tr>
	
	<tr>
		<td colspan="2" align="left"><html:button property="btnCalcular" value="Calcular" onclick="validacionForm()" /></td>
	</tr>
	
	<tr>
		<td colspan="2">&nbsp;</td>
	</tr>
	
	</table>
	
	<div style="background-color: #0066bb;">
		<font face="Arial Narrow" size=3 color="#FFFFFF"><b>&nbsp;Cálculo de la Nueva Cuota</b></font>
	</div>
	
	<br/>
	<table width="50%" height="100%" border="0" cellspacing="0" cellpadding="0">
	
	<tr>
	<td>Limite Ajustado</td>
	<td align="left"><html:text property="limiteAjustVal" styleId="limiteAjustVal" style="width: 150px"/></td>
	</tr>
	
	<tr>
	<td>Tasa</td>
	<td align="left"><html:text property="tasaVal" styleId="tasaVal" style="width: 150px"/></td>
	</tr>
	
	<tr>
	<td>Plazo</td>
	<td align="left"><html:text property="plazoVal" styleId="plazoVal" style="width: 150px"/></td>
	</tr>
	
	<tr>
		<td colspan="2">&nbsp;</td>
	</tr>
	
	<tr>
	<td>Cuota</td>
	<td align="left"><html:text property="cuotaVal" styleId="cuotaVal" style="width: 150px"/></td>
	</tr>
	
	<tr>
		<td colspan="2">&nbsp;</td>
	</tr>
	
	<tr>
		<td colspan="2" align="left"><html:button property="btnCalcular" value="Calcular" onclick="validacionFormVal()" /></td>
	</tr>
	
	<tr>
		<td colspan="2">&nbsp;</td>
	</tr>
	
	</table>
	
	<div style="background-color: #0066bb;">
		<font face="Arial Narrow" size=3 color="#FFFFFF"><b>&nbsp;Datos del Cliente</b></font>
	</div>
	
	<br/>
	<table width="40%" border="0" cellspacing="0" cellpadding="0">
	
	<tr>
	<td>Código Central:</td>
	<td align="left"><html:text property="codCentral" styleId="codCentral" style="width: 300px"/></td>
	</tr>
	
	<tr>
	<td>Nombres:</td>
	<td align="left"><html:text property="nomCliente" styleId="nomCliente" style="width: 300px"/></td>
	</tr>
	
	<tr>
	<td>Documento:</td>
	<td align="left"><html:text property="numDocumento" styleId="numDocumento" style="width: 300px"/></td>
	</tr>
	
	<tr>
	<td>Score Buro:</td>
	<td align="left"><html:text property="scoreBuro" styleId="scoreBuro" style="width: 300px"/></td>
	</tr>
	
	<tr>
	<td>Sobreendeudamiento:</td>
	<td align="left"><html:text property="sobreEndeudamiento" styleId="sobreEndeudamiento" style="width: 300px"/></td>
	</tr>
	
	<tr>
	<td>Clasificación BBVA:</td>
	<td align="left"><html:text property="clasifBBVA" styleId="clasifBBVA" style="width: 300px"/></td>
	</tr>
	
	<tr>
	<td>Clasificación S. Financiero:</td>
	<td align="left"><html:text property="clasifFinanciero" styleId="clasifFinanciero" style="width: 300px"/></td>
	</tr>
	
	<tr>
	<td>Fecha de evaluación:</td>
	<td align="left"><html:text property="fecEvaluacion" styleId="fecEvaluacion" style="width: 300px"/></td>
	</tr>
	
	<tr>
	<td>Calificación Total:</td>
	<td align="left"><html:text property="califTotal" styleId="califTotal" style="width: 300px"/></td>
	</tr>
	
	<tr>
	<td>Calificación Disponible:</td>
	<td align="left"><html:text property="califDisponible" styleId="califDisponible" style="width: 300px"/></td>
	</tr>
	</table>
	
</html:form>
</body>
</html>